Skip to content

Add library for humility dump#698

Open
labbott wants to merge 17 commits into
masterfrom
humility-dump-lib
Open

Add library for humility dump#698
labbott wants to merge 17 commits into
masterfrom
humility-dump-lib

Conversation

@labbott

@labbott labbott commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This is broken up into two commits

  1. Refactor humility dump to make some of the logic easier to follow
  2. Add the dumping library

Because of the way humility dump currently works it's tricky to have all the library functions replace the same functions in the binary. Almost tempted to say we should start from scratch with humility dump-ng but that's probably a bad idea.

@labbott labbott force-pushed the humility-dump-lib branch 2 times, most recently from 9fb35b1 to 863bb7d Compare June 12, 2026 18:12
@mkeeter mkeeter self-requested a review June 16, 2026 14:56
Comment thread humility-dump-lib/Cargo.toml Outdated
Comment thread humility-dump-lib/Cargo.toml Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump/src/lib.rs Outdated
.map_err(DumpError::UdpAgent)?,
))
} else {
// XXX

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XXX?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a reminder that I grabbed a timeout instead of having it passed in. I'm also looking at the code and timeout doesn't get used anywhere except humility-net-core which is the exact opposite case here! I might take a pass to fix this up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still like to fix this but I don't know if I want to depend on this so I cleaned it up with a comment for now.

Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
pub fn take_system_dump_via_agent(
hubris: &HubrisArchive,
core: &mut dyn Core,
dumpfile: Option<&PathBuf>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love having the naming logic in the library (I would be happier if this took a std::io::Write handle), but that's annoying to fix right now since it's actually in HubrisArchive::dump.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a pass at pulling this out. It wasn't too bad.

Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump/src/lib.rs
let headers =
agent.read_dump_headers(false).map_err(DumpError::DumpHeaders)?;

if headers.is_empty() || headers[0].0.dumper == humpty::DUMPER_NONE {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: because we pass raw: false to read_dump_headers, is it even possible to get DUMPER_NONE?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

("This is how it worked before and I don't want to deal with it in this PR" is a valid response here)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was copy/pasting the existing logic. I think you are correct but I'm lightly wary to remove it without more testing. I might just add another comment.

Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump/src/lib.rs
Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
Comment thread humility-dump-lib/src/lib.rs Outdated
labbott added 11 commits June 22, 2026 10:26
This function has grown complicated and hard to follow. Extract
the following to separate functions

- `subargs.initialize_dump_agent`
- `subargs.simulate_dumper`/`subargs.emulate_dumper`/
   `subargs.simulate_task_dump`
- `subargs.extract`/`subargs.force_read`

There's a little bit of redundancy but it makes the logic much
easier to follow.
One of the most common uses for humility is to take an SP dump on a
system so it can be analyzed later. Having this as a library
function makes it easier to do it more places.
This reverts commit 9552bf5.
@labbott labbott force-pushed the humility-dump-lib branch from 863bb7d to 38b5774 Compare June 23, 2026 14:09
Comment thread cmd/dump/src/lib.rs
let mut file = std::fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(stock)?;

@mkeeter mkeeter Jun 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this no longer prints dumping to {filename}; I'm ambivalent on whether that matters

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also true elsewhere)

Comment thread humility-dump/src/lib.rs
Ok(())
}

/// Take and collect a dump via the agent. If a file is not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring is now outdated, since we pass in a std::io::Write

Comment thread humility-dump/src/lib.rs
Comment on lines +329 to +330
likely due to space exhaustion; \
dump will be extracted but may be incomplete!"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indentation

Suggested change
likely due to space exhaustion; \
dump will be extracted but may be incomplete!"
likely due to space exhaustion; \
dump will be extracted but may be incomplete!"

Comment thread humility-dump/src/lib.rs
}

/// List all available dumps
pub fn list_dumps_via_agent(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rename to list_dumps, because there's no DumpAgent in the signature?

@mkeeter

mkeeter commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Looks good, approved with a few nits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants